package org.bilinc.gz001;

import org.bilinc.gz001.hibernateUtil.AppContextHolder;

import javax.swing.*;
import java.util.Random;

public class Application {

    public static final boolean DEBUG = true;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                } catch (ClassNotFoundException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                } catch (InstantiationException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                } catch (IllegalAccessException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                } catch (UnsupportedLookAndFeelException e) {
                    e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
                }
                /*You are not gonna believe, Ivan Barnov, we have Spring here*/
                AppContextHolder.getAppContext();

                /*Model*/
                /*Implicitly call this bean to accept autowiring from its*/
                ModelService modelService = AppContextHolder.getAppContext().getAutowireCapableBeanFactory().getBean(ModelService.class);
                modelService.initialize();

                /*View*/
                UserInterface userInterface = new UserInterface(modelService);
                /*Controller*/
                ApplicationController controller = new ApplicationController(modelService, userInterface);
                /*Random random = new Random();
                modelService.onRowAdd("Москва", "Петушок Кококо", "Руководители", String.valueOf(random.nextInt(1000)+3000), 10);*/

                userInterface.setVisible(true);
            }
        });
    }
}
